package ch.ti.kmltomap;

import org.xmlpull.v1.XmlPullParser;

import com.google.android.gms.maps.GoogleMap;

public class LinearRing extends Geometry {

	private Coordinates coordinates = null;
	
	public LinearRing(){}
	
	public LinearRing(XmlPullParser xpp){
		try{
			this.id = xpp.getAttributeValue(null, "id");
			int eventType = xpp.next();
			String tagName = "";
			while (eventType != XmlPullParser.END_DOCUMENT) {
				if(eventType == XmlPullParser.START_TAG){
					tagName = xpp.getName();
				}
				if(eventType == XmlPullParser.TEXT){
					if(tagName.equals("coordinates")){
						this.addCoordinatesString(xpp.getText().trim());
					}
				}else if(eventType == XmlPullParser.END_TAG){
					if(xpp.getName().equals("LinearRing")){
						break;
					}
				}
				eventType = xpp.next();
			}
		}catch (Exception e) {
		}			
	}
	
	public void addCoordinate(Coordinate coordinate){
		this.coordinates.coordinates().add(coordinate);
	}
	
	public void addCoordinatesString(String coordinates){
		this.coordinates = new Coordinates(coordinates);
	}
	
	public Coordinates coordinates(){
		return this.coordinates;
	}

	@Override
	public void draw(GoogleMap map, String testo) {
		
		
	}
	
}
